package com.ct.ah.lab.controller;

import com.ct.ah.lab.entity.Category;
import com.ct.ah.lab.service.ICategoryService;
import com.ct.ah.lab.service.IUserService;
import com.ct.ah.lab.service.impl.CategoryServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class CategoryController{
    @Autowired
    private ICategoryService categoryService;

    @RequestMapping("/products/findAllCategory")
    @ResponseBody
    public Map<String,Object> findAllCategory(){
        Map<String,Object> map = new HashMap<>();

        List<Category> categories = categoryService.list();
        map.put("state",1000);
        map.put("data",categories);

        return map;
    }
}
